<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/extras/spring-security">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <!-- 避免IE使用兼容模式 -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <!-- TopJUI框架样式 -->
    <link type="text/css" href="/topjui/themes/default/topjui.core.min.css" rel="stylesheet">
    <link type="text/css" href="/topjui/themes/default/topjui.blue.css" rel="stylesheet" id="dynamicTheme"/>
    <!-- FontAwesome字体图标 -->
    <link type="text/css" href="/static/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet"/>
    <!-- layui框架样式 -->
    <link type="text/css" href="/static/plugins/layui/css/layui.css" rel="stylesheet"/>
    <!-- iconfont字体图标 -->
	<link type="text/css" href="/static/plugins/iconfont/iconfont.css" rel="stylesheet"/>
    <!-- ztree css -->
	<link rel="stylesheet" href="/static/plugins/zTree/css/zTreeStyle/zTreeStyle.css" type="text/css">
    
    <!-- jQuery相关引用 -->
    <script type="text/javascript" src="/static/plugins/jquery/jquery.min.js"></script>
    <script type="text/javascript" src="/static/plugins/jquery/jquery.cookie.js"></script>
    <!-- TopJUI框架配置 -->
    <script type="text/javascript" src="/static/public/js/topjui.config.js"></script>
    <!-- TopJUI框架核心-->
    <script type="text/javascript" src="/topjui/js/topjui.core.min.js"></script>
    <!-- TopJUI中文支持 -->
    <script type="text/javascript" src="/topjui/js/locale/topjui.lang.zh_CN.js"></script>
    <!-- layui框架js -->
    <script type="text/javascript" src="/static/plugins/layui/layui.js" charset="utf-8"></script>
    <!-- ztree js -->
	<script type="text/javascript" src="/static/plugins/zTree/js/jquery.ztree.core.js"></script>
	<script type="text/javascript" src="/static/plugins/zTree/js/jquery.ztree.excheck.js"></script>
</head>

<body>
	<div sec:authorize="hasAuthority('system:user')" data-toggle="topjui-layout" data-options="fit:true">
	    <div sec:authorize="hasAuthority('system:user:list')" data-options="region:'center',title:'',split:true,border:false,bodyCls:'border_right'">
			<table id="sysUser-list" data-toggle="topjui-datagrid" data-options="
				id:'sysUser-list',url:'/system/user/list',
				fitColumns:true,singleSelect:true,selectOnCheck:false,checkOnSelect:false,pageSize:50">
				<thead>
					<tr>
						<th data-options="field:'id',title:'ID',checkbox:true"></th>
						<th data-options="field:'username',title:'用户名',width:100"></th>
						<th data-options="field:'nickname',title:'用户昵称',width:100"></th>
						<th data-options="field:'roleNames',title:'关联角色',width:100"></th>
						<th data-options="field:'password',title:'密码',width:100,hidden:true"></th>
						<th data-options="field:'avatar',title:'头像',width:100,hidden:true"></th>
						<th data-options="field:'email',title:'邮箱',width:100,hidden:true"></th>
						<th data-options="field:'mobile',title:'电话',width:100,hidden:true"></th>
						<th data-options="field:'address',title:'地址',width:100,hidden:true"></th>
						<th data-options="field:'gender',title:'性别',width:50,hidden:true,
							formatter:function(value,row,index){
								if (value == '0') {
									return '<label style=\'color: green;\'>男</label>';
								} else if (value == '1') {
									return '<label style=\'color: red;\'>女</label>';
								} else {
									return '';
								}
							}"></th>
						<th data-options="field:'status',title:'状态',width:50,
							formatter:function(value,row,index){
								if (value == '0') {
									return '<label style=\'color: green;\'>启用</label>';
								} else if (value == '1') {
									return '<label style=\'color: red;\'>停用</label>';
								} else {
									return '';
								}
							}"></th>
						<th data-options="field:'remark',title:'备注',width:100"></th>
						<th data-options="field:'updateTime',title:'操作时间',width:100"></th>
					</tr>
				</thead>
			</table>
		</div>
		
		<div sec:authorize="hasAuthority('system:user:menu')" id="sysMenu-div" data-options="region:'east',width:'25%',title:'',split:true,border:false,bodyCls:'border_left_right'">
			<!-- 标签栏（用户权限） -->
			<div id="sysMenu-bar" style="visibility: hidden;">
				<a href="javascript:void(0)" data-toggle="topjui-menubutton" data-options="disabled:true,iconCls:'fa fa-lock'">用户权限</a>
			</div>
			
			<!-- 用户权限-ZTree -->
			<div style="padding-top: 40px;padding-bottom: 10px;">
				<ul id="sysMenu-tree" class="ztree" style="visibility: hidden;"></ul>
			</div>
		</div>
	</div>
	
	<!-- 表格工具栏 -->
	<div sec:authorize="hasAuthority('system:user:list')" id="sysUser-list-toolbar" class="topjui-toolbar" data-options="grid:{type:'datagrid', id:'sysUser-list'}">
		<a sec:authorize="hasAuthority('system:user:add')" href="javascript:void(0)" data-toggle="topjui-menubutton" data-options="
			method:'openDialog',
			extend:'#sysUser-list-toolbar',
			iconCls:'fa fa-plus',
			dialog:{
  				id:'sysUser-add-dialog',
				title:'新增用户',
				href:'/system/user/add_view',
				width:'70%',
				height:'70%',
				buttonsGroup:[{
					text:'确定',
					url:'/system/user/add',
					iconCls:'fa fa-plus',
					handler:'ajaxForm',
					btnCls:'topjui-btn-green'
				}]
			}">新增</a>
		
		<a sec:authorize="hasAuthority('system:user:edit')" href="javascript:void(0)" data-toggle="topjui-menubutton" data-options="
			method:'openDialog',
			extend:'#sysUser-list-toolbar',
			iconCls:'fa fa-pencil',
			dialog:{
				id:'sysUser-edit-dialog',
				title:'编辑用户',
				href: '/system/user/edit_view/{id}',
				width:'70%',
				height:'70%',
				buttonsGroup:[{
					text:'确定',
					url:'/system/user/edit',
					iconCls:'fa fa-plus',
					handler:'ajaxForm',
					btnCls:'topjui-btn-green'
				}]
			}">编辑</a>
		
		<a sec:authorize="hasAuthority('system:user:delete')" href="javascript:void(0)" data-toggle="topjui-menubutton" data-options="
			method:'doAjax',
			extend:'#sysUser-list-toolbar',
			iconCls:'fa fa-trash',
			confirmMsg:'确认删除已选择的数据？',
			grid: {uncheckedMsg:'请先勾选要删除的数据',param:'ids:id'},
			url:'/system/user/delete'">删除</a>
		
		<form sec:authorize="hasAuthority('system:user:query')" id="queryForm" class="search-box" style="float:right">
			<input type="text" name="username" data-toggle="topjui-textbox" data-options="id:'username',prompt:'名称',width:200">
			<a href="javascript:void(0)" data-toggle="topjui-menubutton" data-options="
				method:'query',
				extend:'#sysUser-list-toolbar',
				iconCls:'fa fa-search',
				form:{id:'queryForm'},
				grid:{type:'datagrid','id':'sysUser-list'}">查询</a>
		</form>
	</div>
</body>

<style>
	#sysMenu-bar {
		width: 100%;
		padding: 3px 2px;
		border-bottom: 1px solid #ddd;
		background-color: #FFF;
		position: fixed;
	}
	#sysMenu-tree {
		width: 100%;
		height: 100%;
    	border: 0;
    	background: #FFF;
	}
	#sysMenu-tree li a {
		text-decoration: none;
	}
</style>

<script type="text/javascript">
	var setting = {
		data : {
			simpleData : {
				enable : true
			}
		}
	};
	
	// 用户列表，选择行事件，初始化菜单树
	$('#sysUser-list').iDatagrid({
		onSelect : function(index, row) {
			if($("#sysMenu-div").length > 0) {
				$("#sysMenu-bar").css('visibility','visible');
				$("#sysMenu-tree").css('visibility','visible');
				$.ajax({
					type : "GET",
					url : "/system/user/menu_tree/" + row.id,
					success : function(result) {
						$.fn.zTree.init($("#sysMenu-tree"), setting, result);
			        }
				});
			}
		}
	});
</script>
</html>